<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ include file="/WEB-INF/views/include/constrant.jsp"%>
<!DOCTYPE html>
<html  lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>接送机</title>
<jsp:include page="/WEB-INF/views/gov/airRent/head.jsp"></jsp:include>
<link href="${ctxStatic }/cityselector/cityselect.css" rel='stylesheet'type='text/css' />
<link href="${ctxStatic }/index/css/airport.css" rel="stylesheet">
<script src="${ctxStatic}/jquery/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctxStatic }/gov/js/messages_zh.js"></script>
<link rel="stylesheet" href="${ctxStatic }/gov/css/gov_total.css" />
<script type="text/javascript">

	$(function() {
		if("${message}".length>0){
			alert("${message}");
		}
		
		$('.funcMenu').click(function() {
			var url = $(this).attr('data-url');
			if (url != '#') {
				window.location.href = $(this).attr('data-url');
			}
		});
		var keyVal2 = "${sessionScope.mes}";
		if(keyVal2.length!=0){  
			alert(keyVal2);
			window.location.href = '${ctxFront }/indexAirRent';
		}
		$('.apt_tits span').click(function(){
			$(this).addClass('apt_t_g').siblings().removeClass('apt_t_g');
		})
		$('.apt_s_j').click(function(){
				$('.oi_port').text('抵达机场：');
				$('.ar_date').text('出发地点：');
		})
		$('.apt_t_g').click(function(){
		$('.oi_port').text('出发机场：');
		$('.ar_date').text('抵达地点：');
		})
		// 机场
		$.post('${ctxFront}/info/site/siteJson',{spottypes:'9'}, function(data) {
			new Vcity.CitySelector({input:'departcity_sitename3',cityData:data});
		});
		// 送达城市
		$.post('${ctxFront}/info/site/siteJson',{spottypes:'0'}, function(data) {
			new Vcity.CitySelector({input:'destcity_sitename3',cityData:data});
		});
		$('.airportRentTab').click(function(){
			$('#airportRentType').val($(this).attr('data-value'));
			//changeShowSpan($(this).attr('data-value'));
		});
	})
function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#airportRentForm").submit();
		return false;
	}
	function changeShowSpan(val){
		if(val=='接机') {
			var span = $('.airportDestcitySpan');
			$(span[0]).text('出发机场     :');
			$(span[1]).text('抵达地点     :');
		} 
		if(val=='送机') {
			var span = $('.airportDestcitySpan');
			$(span[0]).text('抵达机场    :');
			$(span[1]).text('出发地点    :');
			$('#suggestId').attr('placeholder','请输入送达地点')
		}
}
</script>
</head>
<%
session.removeAttribute("mes");
	%>
<body><input type="hidden" id="menuInfo" value="indexAirRent">
<form id="airportRentForm" action="${ctxGov }/airRentList" method="post">
<input type="hidden" name="rentType" value="${ORDER_TYPE_RENTPRODUCT_AIRPLANE }"/>
<input type="hidden" name="mapkm" value="" id="mapkm"/>
<input type="hidden" name="maptime" value="" id="maptime"/>
<input type="hidden" name="mes" value="" id="mes"/>
<input id="airportRentType" type="hidden" name="tabType" value="接机"/>
		<div id="airport">
			<div class="airport_main">
				 <div class="apt_img">
				 	 <img src="${ctxStatic }/index/images/airportbanner.jpg" />
				 </div>
				 <div class="apt_body">
				 	<div class="apt_tits">
				 		<span class="apt_t_g airportRentTab " data-value="接机">接机</span>
				 		<span class="airportRentTab apt_s_j" data-value="送机">送机</span>
				 	 </div>
				 	 <script>
				 	 	$(function(){
				 	 		$('.apt_t_g').click(function(){
				 	 			$('#suggestId').attr('placeholder','请输入抵达地点');
				 	 		});
				 	 		$('.apt_s_j').click(function(){
				 	 			$('#suggestId').attr('placeholder','请输入出发地点');
				 	 		})
				 	 	})
				 	 </script>
				 	<div class="apt_s_box">
				 	     <div class="pick_apt_send">
				 	 	      <div class="apt_sp">
				 	 	      	   <div class="sp_list">
				 	 	      	   	    <label>
				 	 	      	  	          <span class="airportDestcitySpan oi_port">出发机场：</span>
		<input type="text" id="departcity_sitename3" class="display_ib flex_select1 date_3 required" name="departcity.sitename" 
		value="${tRentproduct.departcity.sitename }" placeholder="请选择机场" autocomplete="off">
		<input type="hidden" name="departcity.siteid" value="${tRentproduct.departcity.siteid }">
				 	 	      	         </label>
				 	 	      	   </div>
				 	 	      	   <div class="sp_list">
				 	 	      	   	    <label>
		<span class="airportDestcitySpan ar_date"> 抵达地点：</span>
        <input type="text" id="destcity_sitename3" data-autocity="yes" name="destcity.sitename"
         value="${tRentproduct.destcity.sitename }" class="apt-city" placeholder="选择城市" autocomplete="off">
		<input type="hidden" name="destcity.siteid"  id="destcity.siteid" value="${tRentproduct.destcity.siteid }">
		<input type="text" placeholder="请输入抵达地点" id="suggestId" value="${tRentproduct.remarks }"
		 name="aboardAddress" class="addss apt-date" />
<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
				 	 	      	         </label>
				 	 	      	   </div>
				 	 	      	   <div class="sp_list">
				 	 	      	   	    <label>
				 	 	      	  	          <span>出发时间：</span>
	<input type="text" placeholder="选择日期" class="custom-day Wdate" name="fromdateStr" value="<fmt:formatDate value="${defaultTime}" pattern="yyyy-MM-dd HH:mm"/>"
	  	   	  onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false,maxDate:'${maxDay }',minDate:'%y-%M-%d'})" id="fromdateStr" readonly="readonly"/></label>
				 	 	      	   </div>
				 	 	      	   <div class="apt_btn">
				 	 	      	   	     <a href="javascript:void(0)" id="airportsearch">查询</a>
				 	 	      	   </div>
				 	 	      </div>
				 	 	      
				 	 	      <script>
				 	 	      	//第一种方法
      $(document).ready(function(){
    var doc=document,inputs=doc.getElementsByTagName('input'),supportPlaceholder='placeholder'in doc.createElement('input'),placeholder=function(input){var text=input.getAttribute('placeholder'),defaultValue=input.defaultValue;
    if(defaultValue==''){
        input.value=text}
        input.onfocus=function(){
            if(input.value===text){this.value=''}};
            input.onblur=function(){if(input.value===''){this.value=text}}};
            if(!supportPlaceholder){
                for(var i=0,len=inputs.length;i<len;i++){var input=inputs[i],text=input.getAttribute('placeholder');
                if(input.type==='text'&&text){placeholder(input)}}}});
				 	 	      </script>
				 	 	      
				 	     </div>
				 	</div>				 	
				 </div>
			</div>
		</div>
		</form>
	</body>
</html>
<%@include file="../index/foot.jsp" %>
<script type="text/javascript" src="${ctxStatic }/index/js/map.js"></script>
<script type="text/javascript">
//接送机提交
var km = 0;
var time = 0;
$(function(){
	$("#airportsearch").click(function(){
		if($('#departcity_sitename3').val()=="") {
			alert("机场不能为空");
			return false;
		}
		if($('#destcity_sitename3').val()=="") {
			alert("城市不能为空");
			return false;
		}
		if($('#suggestId').val()=="") {
			alert("请输入详细地址");
			return false;
		}
		var x= $('#suggestId').val();
		var y = $('#departcity_sitename3').val()
		var map = new BMap.Map("allmap");
var output = "从"+y+"到"+x+"驾车预计需要";
var searchComplete = function (results){
	if (transit.getStatus() != BMAP_STATUS_SUCCESS){
		return ;
	}
	var plan = results.getPlan(0);
	output += plan.getDuration(true) + "\n";                //获取时间
	time = plan.getDuration(true);
	$('#maptime').val(time)
	output += "总路程大约为：" ;
	output += plan.getDistance(true) + "\n";             //获取距离
	km = plan.getDistance(true);
	$('#mapkm').val(km);
}
var transit = new BMap.DrivingRoute(map, {renderOptions: {map: map},
	onSearchComplete: searchComplete,
	onPolylinesSet: function(){        
		//$("#distance").html(output);
		$("#mes").val(output);
}});
transit.search(x, y);
window.setTimeout(submitform, 1500); 
function submitform() 
{
	var $time = $("#fromdateStr").val()+" "+$("#time").val();
	$.post("${ctxFront}/sms/checkTime","time="+$time,function(d){
		if(d==1){//"距离发车时间不足2小时，请重新选择发车时间"
			alert("距离发车时间不足2小时，请重新选择出发时间");
			return false;
		}else{
			$('#airportRentForm').submit();
		}
	});
} 
})
	})
</script>